package cn.gok.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @author: chen fan
 * @since: 2022/11/7 10:07
 * @description:
 */
@Controller
@RequestMapping("/user")
public class UserController {


    @RequestMapping("/fail.html")
    public String toFailPage(){
        return "fail";
    }





    @RequestMapping("/login")
    public String login(String userName, String password, HttpSession httpSession){
        if ("zhangsan".equals(userName) && "123456".equals(password)){
            httpSession.setAttribute("userName","zhangsan");
            return "success";
        }
        return "fail";
    }


    @RequestMapping("/getUserInfo")
    public String getUserInfo(ModelMap modelMap){
        modelMap.put("userName","zhangsan");
        modelMap.put("age",19);
        modelMap.put("gender","男");
        return "userInfo";
    }



}
